// part1:C14:14.26:my_StrVec.h
#ifndef MY_STRVEC_H__
#define MY_STRVEC_H__
#include <vector>
class StrVec
{
public:
    StrVec();
    ~StrVec(){}
    friend bool operator==(const StrVec &lhs, const StrVec &rhs);
    friend bool operator!=(const StrVec &lhs, const StrVec &rhs);
    friend bool operator<(const StrVec &lhs, const StrVec &rhs);
    friend bool operator<=(const StrVec &lhs, const StrVec &rhs);
    friend bool operator>(const StrVec &lhs, const StrVec &rhs);
    friend bool operator>=(const StrVec &lhs, const StrVec &rhs);
    std::string& operator[](std::size_t n)
    {
        return elements[n];
    }

    const std::string& operator[](std::size_t n) const
    {
        return elements[n];
    }
};
bool operator==(const StrVec &lhs, const StrVec &rhs)
{
    if (lhs.size() != rhs.size()) 
    {
       return false; 
    }

    for (auto itr1 = lhs.begin(), itr2 = rhs.begin(); itr1 != lhs.end()
            && itr2 != rhs.end(); ++itr1++, ++itr2++) 
    {
        if (*itr1 != *itr2) 
        {
            return false; 
        }    
    }    
    return true;
}
bool operator!=(const StrVec &lhs, const StrVec &rhs)
{
    return !(lhs == rhs);
}


bool operator<(const StrVec &lhs, const StrVec &rhs)
{
    for (auto p1 = lhs.begin(), p2 = lhs.begin(); p1 != lhs.end() &&
            p2 != rhs.end(); ++p1, ++p2) 
    {
         if (*p1 < *p2) {
             return true; 
         }
         else if (*p1 > *p2) 
         {
             return false; 
         }
    }
    if (p1 == lhs.end() && p2 != rhs.end()) {
        return true;
    }
    return false;
}

bool operator<=(const StrVec &lhs, const StrVec &rh)
{
    for (auto p1 = lhs.begin(), p2 = rhs.begin(); p1 != lhs.end() &&
            p2 != rhs.end(); ++p1, ++p2) 
    {
        if (*p1 < *p2) 
        {
            return true;    
        }
        else if (*p1 > *p2) 
        {
            return false;    
        }
    }
    if (p1 == lhs.end()) 
    {
        return true; 
    }
}

bool operator>(const StrVec &lhs, const StrVec &rhs)
{
    for (auto p1 = lhs.begin(), p2 = rhs.begin(); p1 != lhs.end() &&
            p2 != rhs.end(); ++p1, ++p2) 
    {
        if (*p1 < *p2) 
        {
            return false;    
        }
        else if (*p1 > *p2) 
        {
            return true;    
        }
    }
    if (p1 != lhs.end() && p2 == rhs.end()) 
    {
        return true;
    }
    return false;
}
bool operator>=(const StrVec &lhs, const StrVec &rhs)
{
    for (auto p1 = lhs.begin(), p2 = rhs.begin(); p1 != lhs.end() && p2 != rhs.end();
        p1++, p2++)
    {
        if (*p1 < *p2)
        {
            return false;
        }
        else if
        {
            return true;
        }

        if (p2 == rhs.end())
        {
            return true;
        }
    }
    return false;
}
#endif
